package com.ruoyi.flink.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.flink.domain.JobRunLog;
import com.ruoyi.flink.service.IJobRunLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 运行任务日志Controller
 * 
 * @author shu_k
 * @date 2021-04-23
 */
@RestController
@RequestMapping("/flink/JobRunLog")
public class JobRunLogController extends BaseController
{
    @Autowired
    private IJobRunLogService jobRunLogService;

    /**
     * 查询运行任务日志列表
     */
    @PreAuthorize("@ss.hasPermi('flink:JobRunLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(JobRunLog jobRunLog)
    {
        startPage();
        List<JobRunLog> list = jobRunLogService.selectJobRunLogList(jobRunLog);
        return getDataTable(list);
    }

    /**
     * 导出运行任务日志列表
     */
    @PreAuthorize("@ss.hasPermi('flink:JobRunLog:export')")
    @Log(title = "运行任务日志", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(JobRunLog jobRunLog)
    {
        List<JobRunLog> list = jobRunLogService.selectJobRunLogList(jobRunLog);
        ExcelUtil<JobRunLog> util = new ExcelUtil<JobRunLog>(JobRunLog.class);
        return util.exportExcel(list, "运行任务日志数据");
    }

    /**
     * 获取运行任务日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('flink:JobRunLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(jobRunLogService.selectJobRunLogById(id));
    }

    /**
     * 新增运行任务日志
     */
    @PreAuthorize("@ss.hasPermi('flink:JobRunLog:add')")
    @Log(title = "运行任务日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JobRunLog jobRunLog)
    {
        return toAjax(jobRunLogService.insertJobRunLog(jobRunLog));
    }

    /**
     * 修改运行任务日志
     */
    @PreAuthorize("@ss.hasPermi('flink:JobRunLog:edit')")
    @Log(title = "运行任务日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JobRunLog jobRunLog)
    {
        return toAjax(jobRunLogService.updateJobRunLog(jobRunLog));
    }

    /**
     * 删除运行任务日志
     */
    @PreAuthorize("@ss.hasPermi('flink:JobRunLog:remove')")
    @Log(title = "运行任务日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jobRunLogService.deleteJobRunLogByIds(ids));
    }
}
